<?php

?>

<h1>Manage categories</h1>



<div class="search-form" style="display:none">
<?php


?>

</div><!-- search-form -->
<style>
.filetree li{line-height:30px;}
.filetree  li.bb{border-bottom:1px solid #ebebeb}

.filetree li a{color:#333333;text-decoration:none;float:right}
</style>
<script>
$().ready(function(e){
	$(".filetree .bb span").live('click',function(e){
		
		$(this).parent().find('ul').toggle();
	});
});
</script>
	<ol id="browser" class="filetree">
	<?php
	if(!empty($categories)){
		foreach($categories as $key=>$value){
			$subCat = Gadgetcategory::model()->findAllByAttributes(array(
				'parentCategoryId'=>$value->id
			));
	?>
		<li class="bb">
			<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $value->imageUrl;?>' width='16'  height='16' />
			<?php echo $value->name;?></span>
		
			<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$value->id)) ); ?>
			<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$value->id)) ); ?>
			<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$value->id)) ); ?>
			
			
			<?php
			if(!empty($subCat)){
				echo "<ul>";
				foreach($subCat as $k=>$subC){
				
					$subCat1 = Gadgetcategory::model()->findAllByAttributes(array(
						'parentCategoryId'=>$subC->id
					));
					
				
			?>
				<li>
				<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $subC->imageUrl;?>' width='16'  height='16' />
				<?php echo $subC->name;?></span>
				<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$subC->id)) ); ?>
				<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$subC->id)) ); ?>
				<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$subC->id)) ); ?>
				
				
				<?php
				
				// level 1
				if(!empty($subCat1)){
					echo "<ul>";
					foreach($subCat1 as $k1=>$subC1){
				?>
					<li>
					<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $subC1->imageUrl;?>' width='16'  height='16' />
					<?php echo $subC1->name;?></span>
					<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$subC1->id)) ); ?>
					<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$subC1->id)) ); ?>
					<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$subC1->id)) ); ?>
					
					
						<?php
						// level 2
						$subCat2 = Gadgetcategory::model()->findAllByAttributes(array(
							'parentCategoryId'=>$subC1->id
						));
						
						if(!empty($subCat2)){
							echo "<ul>";
							foreach($subCat2 as $k2=>$subC2){
								
						?>
							<li>
							<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $subC2->imageUrl;?>' width='16'  height='16' />
							<?php echo $subC2->name;?></span>
							<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$subC2->id)) ); ?>
							<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$subC2->id)) ); ?>
							<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$subC2->id)) ); ?>
							
							
							
								<?php
								// level 3
								$subCat3 = Gadgetcategory::model()->findAllByAttributes(array(
									'parentCategoryId'=>$subC2->id
								));
								
								if(!empty($subCat3)){
									echo "<ul>";
									foreach($subCat3 as $k3=>$subC3){
										
								?>
									<li>
									<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $subC3->imageUrl;?>' width='16'  height='16' />
									<?php echo $subC3->name;?></span>
									<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$subC3->id)) ); ?>
									<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$subC3->id)) ); ?>
									<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$subC3->id)) ); ?>
									
									
									
										<?php
										// level 4
										$subCat4 = Gadgetcategory::model()->findAllByAttributes(array(
											'parentCategoryId'=>$subC3->id
										));
										
										if(!empty($subCat4)){
											echo "<ul>";
											foreach($subCat4 as $k4=>$subC4){
												
										?>
											<li>
											<span><img src='<?php echo Yii::app()->baseUrl;?>/uploads/categories/fill/16-16/<?php echo $subC4->imageUrl;?>' width='16'  height='16' />
											<?php echo $subC4->name;?></span>
											<?php echo CHtml::link(UserModule::t('<i class="icon-remove"></i>'),Yii::app()->createUrl('/categories/manage/delete',array('id'=>$subC4->id)) ); ?>
											<?php echo CHtml::link(UserModule::t('<i class="icon-edit"></i>'),Yii::app()->createUrl('/categories/manage/update',array('id'=>$subC4->id)) ); ?>
											<?php echo CHtml::link(UserModule::t('<i class="icon-eye-open"></i>'),Yii::app()->createUrl('/categories/manage/view',array('id'=>$subC4->id)) ); ?>
											
											
											
											
												
												
											
											
											
											</li>
										<?php
											}
											echo "</ul>";
										}
										?>

										
										
									
									
									
									</li>
								<?php
									}
									echo "</ul>";
								}
								?>
								
								
							
							
							
							</li>
						<?php
							}
							echo "</ul>";
						}
						?>
					
					
					
					</li>
				<?php
					}
					echo "</ul>";
				}
				?>
				
				
				</li>
			<?php
				}
				echo "</ul>";
			}
			?>
		</li>
		
	<?php
		}
	}
	?>
	
		
		
	</ol>

<?php 
/*
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'gadgetcategory-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'name',
		'description',
		
		array(            // display 'author.username' using an expression
            'name'=>'parentCategoryId',
            'value'=>'(Gadgetcategory::model()->findByPk($data->parentCategoryId)) ? Gadgetcategory::model()->findByPk($data->parentCategoryId)->name : ""',
        ),
		'imageUrl',
		'urlKey',
		
		array(
			'class'=>'CButtonColumn',
		),
	),
));
*/
?>
